PROJECT(libdemo)
SET(TARGET demo)

# 指定生成存放可执行文件的目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# 指定生成存放库文件的目录
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

CMAKE_MINIMUM_REQUIRED(VERSION 1.0)

AUX_SOURCE_DIRECTORY(lib LIBDEMO_SRC)

# 指定生成动态库
ADD_LIBRARY(${TARGET} SHARED ${LIBDEMO_SRC})
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES
	CLEAN_DIRECT_OUTPUT 1)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES
	VERSION 1.2 SOVERSION 1)

# 指定生成静态库
ADD_LIBRARY(${TARGET}_static STATIC ${LIBDEMO_SRC})
SET_TARGET_PROPERTIES(${TARGET}_static PROPERTIES OUTPUT_NAME "${TARGET}")
SET_TARGET_PROPERTIES(${TARGET}_static PROPERTIES
	CLEAN_DIRECT_OUTPUT 1)

# 指定二进制、动态库和静态库安装
INSTALL(TARGETS ${TARGET} ${TARGET}_static
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib)

# 指定普通文件安装
INSTALL(FILES lib/demo.h
	DESTINATION include/${TARGET})

# 指定非目标文件的可执行程序安装
#INSTALL(PROGRAMS rundemo.sh
#	DESTINATION bin)

# 指定目录的安装
#INSTALL(DIRECTORY doc/
#	DESTINATION share/doc/${TARGET})
